:root{
  --bg:#0f172a;
  --panel:#111827;
  --muted:#334155;
  --text:#e5e7eb;
  --text-dim:#cbd5e1;
  --accent:#22d3ee;
  --accent-2:#60a5fa;
  --danger:#ef4444;
  --success:#10b981;
  --warn:#f59e0b;
  --shadow:0 8px 24px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:linear-gradient(160deg, #0b1022, #121a33 60%, #0b1022);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Inter,Arial,"Noto Sans","PingFang SC","Microsoft Yahei","Hiragino Sans GB",sans-serif;
}

.app{
  max-width:980px;
  margin:24px auto;
  padding:16px;
}

.app-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px;
  background:rgba(17,24,39,.6);
  border:1px solid rgba(148,163,184,.12);
  border-radius:14px;
  backdrop-filter: blur(8px);
  box-shadow:var(--shadow);
}

.title{
  display:flex;
  align-items:center;
  gap:12px;
}
.title h1{
  font-size:20px;
  margin:0;
  letter-spacing:.5px;
}
.status{
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  border:1px solid rgba(148,163,184,.2);
}
.status-connected{ background:rgba(16,185,129,.15); color:var(--success); }
.status-connecting{ background:rgba(245,158,11,.15); color:var(--warn); }
.status-disconnected{ background:rgba(239,68,68,.15); color:var(--danger); }

.connection{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.connection input{
  width:280px;
  max-width:60vw;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.35);
  color:var(--text);
  outline:none;
}
.connection button{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.2);
  background:linear-gradient(180deg, rgba(34,211,238,.15), rgba(96,165,250,.15));
  color:var(--text);
  cursor:pointer;
}
.connection button:disabled{
  opacity:.5;
  cursor:not-allowed;
}

.join-bar{
  margin-top:14px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.join-bar input{
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.35);
  color:var(--text);
  outline:none;
}
#nickname{ width:240px; max-width:50vw; }
.join-bar button{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.2);
  background:linear-gradient(180deg, rgba(34,211,238,.15), rgba(96,165,250,.15));
  color:var(--text);
  cursor:pointer;
}
.tools{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-left:auto;
}
.tools button{
  background:rgba(2,6,23,.5);
  border:1px solid rgba(148,163,184,.18);
}
.autoscroll{ font-size:13px; color:var(--text-dim); display:flex; align-items:center; gap:6px; }

.chat{
  margin-top:14px;
  background:rgba(17,24,39,.55);
  border:1px solid rgba(148,163,184,.12);
  border-radius:14px;
  min-height:360px;
  max-height:56vh;
  overflow:auto;
  box-shadow:var(--shadow);
}
.messages{
  list-style:none;
  margin:0;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.msg{
  display:flex;
  gap:10px;
  align-items:flex-end;
}
.msg .bubble{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.5);
  max-width:70%;
  white-space:pre-wrap;
  word-break:break-word;
}
.msg.meta .bubble{
  font-size:12px;
  color:var(--text-dim);
  background:transparent;
  border-color:transparent;
}
.msg.self{ justify-content:flex-end; }
.msg.self .bubble{
  background:linear-gradient(180deg, rgba(34,211,238,.18), rgba(96,165,250,.18));
  border-color:rgba(148,163,184,.28);
}
.msg .meta{
  font-size:11px;
  color:var(--text-dim);
}

.composer{
  margin-top:12px;
  display:flex;
  gap:10px;
}
#messageInput{
  flex:1;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.35);
  color:var(--text);
  outline:none;
}
#sendBtn{
  padding:12px 16px;
  border-radius:12px;
  border:1px solid rgba(148,163,184,.2);
  background:linear-gradient(180deg, rgba(34,211,238,.15), rgba(96,165,250,.15));
  color:var(--text);
  cursor:pointer;
}
#sendBtn:disabled{ opacity:.5; cursor:not-allowed; }

.tips{
  margin-top:12px;
  color:var(--text-dim);
  font-size:13px;
}
.tips ul{ margin:6px 0 0 18px; }